package exceptions;

public class DBException extends MyException {
	/*
	 * DBExceptions 
	 */
	private static final long serialVersionUID = 1L;
	
	public static final int DEFAULT 				= -100;
	public static final int VALUE_NOT_FOUND 		= -101;
	public static final int CLOSE 					= -102;
	public static final int VALUE_ALREADY_EXISTS 	= -103;
	public static final int BAD_PARAMS				= -104;

	private String table;
	private String query;

	public DBException(String message) {
		super(message);
	}

	public DBException(String _table, String _query, String _msg, int _errorCode) {
		this.table = _table == null ? "NOT_IMPORTANT" : new String(_table);
		this.query = _query == null ? "NOT_IMPORTANT" : new String(_query);
		this.msg = new String(_msg);
		this.errCode = _errorCode;
	}

	public String getTable() {
		return this.table;
	}

	public String getQuery() {
		return this.query;
	}

	public void print() {
		System.out.print("TABLE: " + this.table + "\nQuery: " + this.query
				+ "\nMSG :" + this.msg + "\nERR CODE : " + this.errCode);
	}

	public boolean isValueNotFoundException() {
		return (this.errCode == VALUE_NOT_FOUND ? true : false);
	}
}